package com.caoyuqi.picture.mapper;

import com.caoyuqi.picture.model.Title;
import com.caoyuqi.picture.model.TitleUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TitleUserMapper {
    @Select("SELECT * from title_user where realname = #{realname}")
    TitleUser queryByRealName(String realname);
    @Insert("insert into title_user(realname,username)values (#{realname},#{username})")
    void InsertIntoUser(String realname,String username);
    @Select("SELECT max(id) from title")
    int MaxTitleId();
    @Select("SELECT * from title ")
    List<Title> queryTitle();
    @Update("UPDATE title_user SET grade = #{grade} WHERE realname = #{username}")
    void UpdateGrade(Integer grade,String username);
    @Update("UPDATE title_user SET zhengquelv = #{currantrate} where realname=#{realname}")
    void UpdateZhengquelv(String currantrate ,String realname);
    @Select("select * from title_user ORDER BY grade desc LIMIT 0 ,2")
    List<TitleUser> queryTop2();
    @Select("select * from title_user ORDER BY grade desc LIMIT 0 ,4")
    List<TitleUser> queryTop4();
}